package com.zq.learn.springbatch.combination.batch;

import com.zq.learn.springbatch.mongo.StatisticsResult;
import com.zq.learn.springbatch.mongo.sourcedata.SourceData;
import org.springframework.batch.item.ItemProcessor;

/**
 * OrderCountProcessor
 *
 * @author ZhangQi
 * @date 2020/2/19
 */
public class OrderCountProcessor implements ItemProcessor<SourceData, StatisticsResult> {
  //数量累积
  private int count=0;

  @Override public StatisticsResult process(SourceData sourceData) throws Exception {
    ++count;
    String day = sourceData.getTimestamp().substring(0, 8);
    return new StatisticsResult("count_" + day, day, "count", count);
  }
}
